home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / telecom / t-sign.zip / T-SIGN.PAS < prev    next >
Pascal/Delphi Source File  |  1996-09-23  |  2KB  |  101 lines

  1. Program T_Sign;
  2.  
  3. Var
  4.  
  5.   InFile,
  6.   OutFile,
  7.   SigFile   : Text;
  8.  
  9.   InBuffer,
  10.   OutBuffer,
  11.   SigBuffer : Array[1..4096] of Char;
  12.  
  13.   S1,S2     : String;
  14.  
  15.   Function StUpCase(S : String) : String;
  16.   Var
  17.     SLen : Byte Absolute S;
  18.     x    : Integer;
  19.   Begin
  20.     For x := 1 To SLen Do S[x]:=UpCase(S[x]);
  21.     StUpCase := S;
  22.   End;
  23.  
  24.  
  25. Begin
  26.  
  27.   WriteLn(#10#10#10#13'TerMail message signing... *FREEWARE* by Bo Bendtsen');
  28.   If ParamCount<>2 Then
  29.   Begin
  30.     WriteLn(#10'Syntax : T-SIGN textfile-to-sign signature-file');
  31.     WriteLn(   'Example: T-SIGN CURRENT.MSG T-SIGN.SIG');
  32.     WriteLn(   '         TM.CFG -> SHIFTF4 T-SIGN !MSG T-SIGN.SIG !R');
  33.     Halt;
  34.   End;
  35.  
  36.   Assign(SigFile,Paramstr(2));
  37.   SetTextBuf(SigFile,SigBuffer);
  38.   {$I-} Reset(SigFile); {$I+}
  39.   If IOResult<>0 Then
  40.   Begin
  41.     WriteLn(#10'Signature file not found: ',Paramstr(2));
  42.     Halt;
  43.   End;
  44.  
  45.   Assign(InFile,Paramstr(1));
  46.   SetTextBuf(InFile,InBuffer);
  47.   {$I-} Reset(InFile); {$I+}
  48.   If IOResult<>0 Then
  49.   Begin
  50.     Close(SigFile);
  51.     WriteLn(#10'File to sign not found: ',Paramstr(1));
  52.     Halt;
  53.   End;
  54.  
  55.  
  56.   Assign(OutFile,'TMP.SIG');
  57.   SetTextBuf(OutFile,OutBuffer);
  58.   {$I-} Rewrite(OutFile); {$I+}
  59.   If IOResult<>0 Then
  60.   Begin
  61.     Close(InFile);
  62.     Close(SigFile);
  63.     WriteLn(#10'Could not create temporary file TMP.SIG');
  64.     Halt;
  65.   End;
  66.  
  67.   S2:='';
  68.  
  69.   While Not Eof(InFile) Do
  70.   Begin
  71.     ReadLn(InFile,S1);
  72.     If Pos('--- TER',StUpcase(S1))<>1 Then WriteLn(OutFile,S1)
  73.     Else Begin
  74.       S2:=S1;
  75.       Break;
  76.     End;
  77.   End;
  78.  
  79.   While Not Eof(SigFile) Do
  80.   Begin
  81.     ReadLn(SigFile,S1);
  82.     WriteLn(OutFile,S1);
  83.   End;
  84.  
  85.   If S2<>'' Then WriteLn(OutFile,S2);
  86.  
  87.   While Not Eof(InFile) Do
  88.   Begin
  89.     ReadLn(InFile,S1);
  90.     WriteLn(OutFile,S1)
  91.   End;
  92.  
  93.   Close(InFile);
  94.   Close(OutFile);
  95.   Close(SigFile);
  96.  
  97.   Erase(InFile);
  98.   Rename(OutFile,Paramstr(1));
  99.  
  100. End.
  101.